home *** CD-ROM | disk | FTP | other *** search
/ CD Classic 39 / CD CLASSIC #39 (1998).iso / EMPRESA / visio / Vistdstd / Install / Data.Z / VB Event Sample.FRM < prev    next >
Text File  |  1996-09-20  |  3KB  |  95 lines

  1. VERSION 4.00
  2. Begin VB.Form UserForm1 
  3.    Caption         =   "Event Sample"
  4.    ClientHeight    =   510
  5.    ClientLeft      =   1740
  6.    ClientTop       =   1860
  7.    ClientWidth     =   5505
  8.    Height          =   915
  9.    Left            =   1680
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   510
  12.    ScaleWidth      =   5505
  13.    Top             =   1515
  14.    Width           =   5625
  15.    Begin VB.TextBox TextBox1 
  16.       Height          =   285
  17.       Left            =   1680
  18.       TabIndex        =   1
  19.       Top             =   120
  20.       Width           =   3615
  21.    End
  22.    Begin VB.Label Label1 
  23.       Caption         =   "Received Event ----->"
  24.       Height          =   255
  25.       Left            =   120
  26.       TabIndex        =   0
  27.       Top             =   120
  28.       Width           =   1575
  29.    End
  30. End
  31. Attribute VB_Name = "UserForm1"
  32. Attribute VB_Creatable = False
  33. Attribute VB_Exposed = False
  34. ' -------------------------------------------------------------------------
  35. ' Copyright (C) 1996 Visio Corporation
  36. '
  37. ' You have a royalty-free right to use, modify, reproduce and distribute
  38. ' the Sample Application Files (and/or any modified version) in any way
  39. ' you find useful, provided that you agree that Visio has no warranty,
  40. ' obligations or liability for any Sample Application Files.
  41. ' -------------------------------------------------------------------------
  42. Option Explicit
  43.  
  44. Dim g_Sink As EventSink         ' instance of class EventSink
  45. Dim g_Event As Visio.Event      ' Event object
  46. Dim docObj As Visio.Document
  47.  
  48. Private Sub Form_Load()
  49. ' Developing Visio Solutions, Chapter 15, Handling Events in Visio
  50. ' This example demonstrates:
  51. '   creating/retrieving a Visio instance
  52. '   creating an instance of a sink object
  53. '   adding a new drawing
  54. '   retrieving the eventlist for a document
  55. '   adding an event that runs an add-on
  56. '   adding an event that sends a notification
  57.  
  58. Dim eventsObj As Visio.EventList
  59.     
  60.     ' Get the current instance of Visio if it is running or create a new one
  61.     ' vaoGetObject is a helper utility found in visreg.bas
  62.     If vaoGetObject() <> visOK Then
  63.         MsgBox "Unable to load Visio!"
  64.     End If
  65.         
  66.     ' Create an instance of the EventSink class
  67.     ' g_Sink in global to the form.
  68.     Set g_Sink = New EventSink
  69.     
  70.     ' Create a new drawing.
  71.     Set docObj = g_appVisio.Documents.Add("")
  72.     
  73.     ' Get the EventList collection of this document.
  74.     Set eventsObj = docObj.EventList
  75.     
  76.     ' Add an Event object that will run an add-on when the event fires.
  77.     ' g_Event is global to this form
  78.     Set g_Event = eventsObj.Add(visEvtShape + visEvtAdd, visActCodeRunAddon, _
  79.         "ShowArgs.exe", "/args=Shape added!")
  80.        
  81.     ' Add event objects that will send notifications.
  82.     
  83.     ' Add an Event object for the DocumentSaved event.
  84.     eventsObj.AddAdvise visEvtCodeDocSave, g_Sink, "", "Document Saved..."
  85.  
  86.     ' Add an Event object for the ShapeDeleted event.
  87.     eventsObj.AddAdvise visEvtCodeShapeDelete, g_Sink, "", "Shape Deleted..."
  88.     
  89.     ' Add an Event object for the PageAdded event.
  90.     eventsObj.AddAdvise (visEvtPage + visEvtAdd), g_Sink, "", "Page Added..."
  91.     
  92. End Sub
  93.  
  94.  
  95.